#include "Observer.hpp"
#include "Subject.hpp"
#include <iostream>

void Test()
{
  // 主题
  WeatherData *pwd = new WeatherData();

  // 观察者
  StatisticsDisplay *pssd = new StatisticsDisplay(pwd);
  ForecastDisplay *pfcd = new ForecastDisplay(pwd);
  CurrentConditionDisplay *pccd = new CurrentConditionDisplay(pwd);

  // 插入数据
  srand((unsigned int)time(nullptr));
  for (int i = 0; i < 10; i++)
  {
    float temp = rand() % 15 + 10;
    float humidity = rand() % 80 + 20;
    float pressure = rand() % 10 + 95;
    pwd->SetMeasures(temp, humidity, pressure);
    sleep(3);

    // if (i == 1)
    // {
    //   pssd->Remove();
    //   pfcd->Remove();
    //   pccd->Remove();
    // }
    // if (i == 3)
    // {
    //   pssd->Register();
    //   pfcd->Register();
    //   pccd->Register();
    // }
    std::cout << std::endl;
  }

  delete pccd;
  delete pssd;
  delete pfcd;
  delete pwd;
}

int main()
{
  Test();
  return 0;
}
